import { Navigate } from "react-router-dom";
import { Suspense, lazy } from "react";
import { Spin } from "antd";
import login from "./modules/login";
import Home from "@/pages/home";
import User from "@/pages/user";

const Entry = lazy(() => import("@/pages/entry"));
const router = [
    {
        path: "/",
        element: (
            <Suspense fallback={<Spin />}>
                <Entry />
            </Suspense>
        ),
        children: [
            {
                path: "/home",
                element: <Home />,
            },
            {
                path: "/user",
                element: <User />,
            },
            {
                path: "/",
                element: <Navigate to="/home" />,
            },
            {
                path: "*",
                element: <Navigate to="/login" />,
            },
        ],
    },
    ...login,
];

export default router;
